package com.itheima.listener;

import com.itheima.domain.mongo.MovementScore;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "recomment-movement-group", topic = "recomment-movement")
public class MovementScoreListener implements RocketMQListener<MovementScore> {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void onMessage(MovementScore movementScore) {
        System.out.println("接收圈子推荐消息：" + movementScore);

        mongoTemplate.save(movementScore);
    }
}
